<template>
  <div class="discountProduct">
    <!-- 查询条件 -->
    <el-form :model="ruleForm" ref="ruleForm" size="mini">
      <div style="display: flex">
        <el-form-item
          label="政策编号"
          prop="name"
          style="display: flex; margin: 0 20px 0 0"
        >
          <el-input size="mini" v-model="ruleForm.id"></el-input>
        </el-form-item>
        <!-- <el-form-item
          label="到达地"
          prop="name"
          style="display: flex; margin: 0 20px 0 0"
        >
          <el-input v-model="ruleForm.destination"></el-input>
        </el-form-item> -->
        <el-form-item label="航空公司" prop="name" style="display: flex">
          <el-select clearable filterable v-model="ruleForm.airline" style="width:231px" placeholder="请选择">
            <el-option
              v-for="(item , index) in airportLists"
              :key="index"
              :label="item.airlinerId+item.airliner"
              :value="item.airlinerId"
            >
            </el-option>
          </el-select>
        </el-form-item>
         <el-form-item
          label="政策开始时间"
          prop="name"
          style="display: flex; margin: 0 20px 0 20px"
        >
          <el-date-picker
            :value-format="format"
            size="mini"
            style="width: 140px"
            type="date"
            placeholder="选择日期"
            v-model="ruleForm.startTime"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item
          label="政策结束时间"
          prop="name"
          style="display: flex; margin: 0 20px 0 0"
        >
          <el-date-picker
            v-model="ruleForm.endTime"
            :value-format="format"
            size="mini"
            style="width: 140px"
            type="date"
            placeholder="选择日期"
          >
          </el-date-picker>
        </el-form-item>
      </div>
      <!-- <div style="display: flex"> -->
       
        <!-- <el-form-item label="合作商" prop="name" style="display: flex">
          <el-select v-model="ruleForm.partner" placeholder="请选择">
            <el-option
              v-for="item in imagestate"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item> -->
      <!-- </div> -->

      <el-form-item style="margin: 0 0 20px 85%">
        <el-button
          type="primary"
          size="mini"
          @click="seachBtn"
          >查询</el-button
        >
        <el-button type="primary" size="mini" @click="newairPort"
          >新增</el-button
        >
      </el-form-item>
    </el-form>
    <!-- 列表 -->
    <el-table
      :header-cell-style="{
        color: '#fff',
        background: '#6090EC',
        fontSize: '11px',
        fontWeight: 'normal',
      }"
      :data="auxiliary"
      size="mini"
      border
      stripe
    >
      <el-table-column
        label="政策编号"
        prop="reviseid"
        width="80"
      ></el-table-column>
      <el-table-column
        label="航空公司"
        prop="airlinerName"
        width="160"
      ></el-table-column>
      <el-table-column  label="舱位" prop="cabin"></el-table-column>
      <el-table-column
        label="调整类型"
        width="80"
        prop="adjustTypeName"
      ></el-table-column>
      <el-table-column
        label="金额/比例"
        width="100"
        prop="adjustmoney"
      ></el-table-column>
      <el-table-column
        label="政策开始时间"
        width="130"
        prop="policystarttime"
      ></el-table-column>
      <el-table-column
        label="政策结束时间"
        width="130"
        prop="policyendtime"
      ></el-table-column>
      <el-table-column label="是否启用" width="100" prop="enabled">
        <template slot-scope="scope">
          <template v-if="scope.row.enabled == '0'">否</template>
          <template v-if="scope.row.enabled == '1'">是</template>
        </template>
      </el-table-column>
      <el-table-column label="操作人" width="130" prop="employeeName">
      </el-table-column>
      <el-table-column label="操作时间"  prop="operationtime"></el-table-column>

      <el-table-column label="操作" width="150" prop="employee">
        <template slot-scope="scope">
          <el-button
            type="primary"
            @click="editdatamethod(scope.row)"
            size="mini"
            >修改</el-button
          >

          <el-button type="primary" @click="delairPort(scope.row)" size="mini"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <!-- 新增弹窗 -->
    <el-dialog
      center
      title="新增"
      :visible.sync="dialogVisible"
      :close-on-click-modal="false"
      width="90%"
    >
      <el-form
        :model="airportadd"
        ref="ruleForm"
        :rules="rules"
        size="mini"
        style="margin-left: 50px"
      >
        <el-form-item
            label="维护类型"
            prop="cabin"
            style="display: flex; margin: 0 20px 0 0"
          >
             <el-radio v-model="chooseType" label="1">加享产品维护</el-radio>
  <el-radio v-model="chooseType" label="2">行李额维护</el-radio>
          </el-form-item>
        <div style="display: flex; margin: 0 0 15px 0">
          <el-form-item
            label="航空公司"
            prop="airlinerId"
            
            style="display: flex; margin: 0 20px 0 0"
          >
            <el-select
              v-model="airportadd.airlinerId"
              filterable
              placeholder="请选择"
              clearable
            >
              <el-option
                v-for="(item,index) in airportLists"
                :key="index"
                :label="item.airliner"
                :value="item.airlinerId"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            label="舱位"
            prop="cabin"
            style="display: flex; margin: 0 20px 0 0"
          >
            <el-input v-model="airportadd.cabin"></el-input>
          </el-form-item>
          <el-form-item
          prop="policystarttime"
            label="起飞起止时间"
            style="display: flex; margin: 0 20px 0 0"
          >
            <div style="display: flex">
              <el-date-picker
                v-model="airportadd.policystarttime"
                size="mini"
                style="width: 140px"
                placeholder="选择日期"
                :value-format="format"
              >
              </el-date-picker>
              <div>-----</div>
              <el-date-picker
                v-model="airportadd.policyendtime"
                size="mini"
                style="width: 140px"
                placeholder="选择日期"
                :value-format="format"
              >
              </el-date-picker>
            </div>
          </el-form-item>
        </div>
        <div style="display: flex; margin: 0 0 15px 0">
          <!-- <el-form-item
            label="出票城市"
             prop="citycode"
            style="display: flex; margin: 0 20px 0 0"
          >
           
          
            <el-select
              v-model="airportadd.citycode"
              filterable
              placeholder="请选择"
              clearable
            >
              <el-option
                v-for="(item,index) in querySearch"
                :key="index"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item> -->
        
          <el-form-item
            label="预定起止时间"
            prop="issuancestarttime"
            style="display: flex; margin: 0 20px 0 0"
          >
            <div style="display: flex">
              <el-date-picker
                v-model="airportadd.issuancestarttime"
                size="mini"
                style="width: 140px"
                placeholder="选择日期"
                :value-format="format"
              >
              </el-date-picker>
              <div>-----</div>
              <el-date-picker
                v-model="airportadd.issuanceendtime"
                size="mini"
                style="width: 140px"
                placeholder="选择日期"
                :value-format="format"
              >
              </el-date-picker>
            </div>
          </el-form-item>
              <el-form-item
            label="出发城市"
            style="display: flex; margin: 0 20px 0 0"
          >
            <!-- prop="departureList" -->

            <el-select
            reserve-keyword
              multiple
              v-model="airportadd.departureList"
              filterable
              placeholder="请选择"
              clearable
            >
              <el-option
                v-for="(item, index) in querySearch"
                :key="index"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            label="到达城市"
            style="display: flex; margin: 0 20px 0 0"
          >
            <!-- prop="arrivalList" -->

            <el-select
               reserve-keyword
              multiple
              v-model="airportadd.arrivalList"
              filterable
              placeholder="请选择"
              clearable
            >
              <el-option
                v-for="(item, index) in querySearch"
                :key="index"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <span style="color:red;font-size:12px">(为空则代表全选)</span>
        </div>
        <div style="display: flex; margin: 0 0 15px 0">
      
        </div>
        <div style="display: flex; margin: 0 0 15px 0">
          <el-form-item
          prop="suitweekList"
            label="适合周期"
            style="display: flex; margin: 0 20px 0 0"
          >
            <el-checkbox-group v-model="suitweekList">
              <el-checkbox label="1">周一</el-checkbox>
              <el-checkbox label="2">周二</el-checkbox>
              <el-checkbox label="3">周三</el-checkbox>
              <el-checkbox label="4">周四</el-checkbox>
              <el-checkbox label="5">周五</el-checkbox>
              <el-checkbox label="6">周六</el-checkbox>
              <el-checkbox label="7">周日</el-checkbox>
            </el-checkbox-group>
          </el-form-item>
        </div>
        <div style="display: flex; margin: 0 0 15px 0">
          <el-form-item
          prop="accessTypeList"
            label="适合显示区域"
            style="display: flex; margin: 0 20px 0 0"
          >
            <el-checkbox-group v-model="accessTypeList">
              <el-checkbox label="1">CRM</el-checkbox>
              <!-- <el-checkbox label="2">外网</el-checkbox> -->
              <el-checkbox label="3">APP</el-checkbox>
              <el-checkbox label="4">小程序</el-checkbox>
            </el-checkbox-group>
          </el-form-item>
          <el-form-item
          prop="adjusttype"
          :rules="chooseType=='1'?rules.adjusttype:[{required:false}]"
            label="价格调整类型"
            style="display: flex; margin: 0 20px 0 0"
          >
            <el-select
              v-model="airportadd.adjusttype"
              filterable
              placeholder="请选择"
              clearable
            >
              <el-option
                v-for="(item, index) in pricetypeList"
                :key="index"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item
          prop="adjustmoney"
          :rules="chooseType=='1'?rules.adjustmoney:[{required:false}]"
            label="金额比率"
            style="display: flex; margin: 0 20px 0 0"
          >
            <div style="display: flex">
              <el-input style="width: 100px" v-model="airportadd.adjustmoney">
              </el-input>
              <span>下浮请填写负数,按比例时：3%请填写 0.03</span>
            </div>
          </el-form-item>
        </div>

        <div style="display: flex; margin: 0 0 15px 0">
          <el-form-item
          prop="returnType"
          :rules="chooseType=='1'?rules.returnType:[{required:false}]"
            label="返现类型"
            style="display: flex; margin: 0 20px 0 0"
          >
            <el-select
              v-model="airportadd.returnType"
              filterable
              placeholder="请选择"
              clearable
            >
              <el-option
                v-for="(item, index) in pricetypeList"
                :key="index"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item
          prop="returnMoney"
             :rules="chooseType=='1'?rules.returnMoney:[{required:false}]"
            label="返现金额"
            style="display: flex; margin: 0 20px 0 0"
          >
            <el-input v-model="airportadd.returnMoney"></el-input>
          </el-form-item>
          <!-- <el-form-item style="display: flex; margin: 0 20px 0 0" prop="arrcustomername">
            <div style="display: flex">
              <el-checkbox>大客户白名单政策，会员ID：</el-checkbox>
              <el-input
              disabled
                :rows="1"
                type="textarea"
                style="width: 300px"
                v-model="arrcustomername"
              ></el-input>
            </div>
          </el-form-item> -->
          <!-- <el-form-item style="display: flex; margin: 0 20px 0 0">
            <el-button
              size="mini"
              type="primary"
              style="margin-left: 10px"
              @click="selecrdisable = true"
              >查询</el-button
            >
          </el-form-item> -->

          <!-- 查询 -->
          <el-dialog
            append-to-body
            title="查询会员"
            :visible.sync="selecrdisable"
            width="50%"
            center
          >
            <el-form
              :inline="true"
              :model="selectdata"
              class="demo-form-inline"
            >
              <el-form-item label="会员id">
                <el-input
                  size="mini"
                  v-model="selectdata.customerId"
                  placeholder="会员id"
                ></el-input>
              </el-form-item>
              <el-form-item label="会员手机号">
                <el-input
                  size="mini"
                  v-model="selectdata.phone"
                  placeholder="会员手机号"
                ></el-input>
              </el-form-item>
              <el-form-item>
                <el-button
                  type="primary"
                  size="mini"
                  @click="getqueryCRMCustomerData()"
                  >查询</el-button
                >
              </el-form-item>
            </el-form>
            <!-- 列表 -->
            <el-table
              ref="multipleSelection"
              :header-cell-style="{
                color: '#fff',
                background: '#6090EC',
                fontSize: '11px',
                fontWeight: 'normal',
              }"
              :data="custmerdata"
              size="mini"
              border
              stripe
              @selection-change="handleSelectionChange"
            >
              <el-table-column type="selection" width="55"> </el-table-column>
              <el-table-column
                label="会员ID"
                prop="customerId"
              ></el-table-column>
              <el-table-column
                label="会员姓名"
                prop="customerName"
              ></el-table-column>
            </el-table>

            <span slot="footer" class="dialog-footer">
              <el-button @click="selecrdisable = false">取 消</el-button>
              <el-button type="primary" @click="voluationdata">确 定</el-button>
            </span>
          </el-dialog>
        </div>
        <div style="display: flex; margin: 0 0 15px 0">
          <el-form-item
          prop="offLine"
              :rules="chooseType=='1'?rules.offLine:[{required:false}]"
            label="返现类型"
            style="display: flex; margin: 0 20px 0 0"
          >
            <el-radio v-model="airportadd.offLine" label="0">线上返现</el-radio>
            <el-radio v-model="airportadd.offLine" label="1">线下返现</el-radio>
          </el-form-item>
          <el-form-item
          prop="ismatchcabin"
              :rules="chooseType=='1'?rules.ismatchcabin:[{required:false}]"
            label="是否匹配原舱退改签"
            style="display: flex; margin: 0 20px 0 0"
          >
            <el-radio v-model="airportadd.ismatchcabin" label="0">否</el-radio>
            <el-radio v-model="airportadd.ismatchcabin" label="1">是</el-radio>
          </el-form-item>
          <el-form-item
          prop="enabled"
           :rules="chooseType=='1'?rules.enabled:[{required:false}]"
            label="是否激活"
            style="display: flex; margin: 0 20px 0 0"
          >
            <el-radio v-model="airportadd.enabled" label="0">否</el-radio>
            <el-radio v-model="airportadd.enabled" label="1">是</el-radio>
          </el-form-item>
        </div>
        <div style="display: flex; margin: 0 0 15px 0">
          <el-form-item
          prop="cabinalias"
                :rules="chooseType=='1'?rules.cabinalias:[{required:false}]"
            label="舱位标识"
            style="display: flex; margin: 0 20px 0 0"
          >
            <div style="display: flex">
              <el-input
                style="width: 100px"
                v-model="airportadd.cabinalias"
              ></el-input>
              <span style="font-size: 12px"
                >实际返现舱位的的标识，必须正确填写否则无法出票</span
              >
            </div>
          </el-form-item>
          <el-form-item
          prop="salesexplain"
          :rules="chooseType=='1'?rules.salesexplain:[{required:false}]"
            label="促销说明"
            style="display: flex; margin: 0 20px 0 0"
          >
            <el-input
              v-model="airportadd.salesexplain"
              type="textarea"
              :rows="2"
              style="width: 500px"
              placeholder="请输入内容"
            >
            </el-input>
          </el-form-item>
        </div>

        <div style="display: flex; margin: 0 0 15px 0">
          <el-form-item
          prop="cabinTag"
          :rules="chooseType=='1'?rules.cabinTag:[{required:false}]"
            label="舱位标签"
            style="display: flex; margin: 0 20px 0 0"
            placeholder="最多输入20字"
          >
            <el-input
              style="width: 400px"
              v-model="airportadd.cabinTag"
            ></el-input>
          </el-form-item>
          <el-form-item
          prop="cabinGradeName"
             :rules="chooseType=='1'?rules.cabinGradeName:[{required:false}]"
            label="舱位等级名称"
            style="display: flex; margin: 0 20px 0 0"
          >
            <el-input
              style="width: 400px"
              v-model="airportadd.cabinGradeName"
            ></el-input>
          </el-form-item>
        </div>

        <div style="display: flex; margin: 0 0 15px 0">
          <el-form-item
          prop="peopleMin"
                   :rules="chooseType=='1'?rules.peopleMin:[{required:false}]"
            label="人数限制"
            style="display: flex; margin: 0 20px 0 0"
          >
            <div>
              <el-input
                type="number"
                min="0"
                style="width: 100px"
                v-model="airportadd.peopleMin"
              ></el-input>

              <span>------</span>
              <el-input
                style="width: 100px"
                type="number"
                min="0"
                v-model="airportadd.peopleMax"
              ></el-input>
            </div>
          </el-form-item>
          <el-form-item
          prop="ageMin"
           :rules="chooseType=='1'?rules.ageMin:[{required:false}]"
            label="年龄限制"
            style="display: flex; margin: 0 20px 0 0"
          >
            <div>
              <el-input
                type="number"
                min="0"
                max="100"
                style="width: 100px"
                v-model="airportadd.ageMin"
              ></el-input>

              <span>------</span>
              <el-input
                type="number"
                min="0"
                max="100"
                style="width: 100px"
                v-model="airportadd.ageMax"
              ></el-input>
            </div>
          </el-form-item>
          <el-form-item
          prop="credentials"
          :rules="chooseType=='1'?rules.credentials:[{required:false}]"
            label="报销凭证"
            style="display: flex; margin: 0 20px 0 0"
          >
            <div>
              <el-select
                v-model="airportadd.credentials"
                filterable
                placeholder="请选择"
                clearable
              >
                <el-option
                  v-for="(item, index) in credentialsList"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </div>
          </el-form-item>
        </div>
        <div style="display: flex; margin: 0 0 15px 0">
            <el-form-item
          prop="baggage"
           :rules="chooseType=='2'?rules.baggage:[{required:false}]"
            label="行李额说明"
            style="display: flex; margin: 0 20px 0 0"
          >
            <el-input
              v-model="airportadd.baggage"
              type="textarea"
              :rows="2"
              style="width: 500px"
              placeholder="请输入内容"
            >
            </el-input>
          </el-form-item>
        </div>

        <div style="display: flex; margin: 0 0 15px 0">
          <el-form-item
          
            label="证件类型"
            style="display: flex; margin: 0 20px 0 0"
          >
            <div>
              <el-select
                v-model="airportadd.idType"
                filterable
                placeholder="请选择"
                clearable
              >
                <el-option
                  v-for="(item, index) in idTypeList"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </div>
          </el-form-item>

          <el-form-item
         
            label="证件号段"
            style="display: flex; margin: 0 20px 0 0"
          >
            <el-input
              style="width: 500px"
              v-model="airportadd.idBigint"
            ></el-input>
          </el-form-item>
          <el-form-item
            label="描述：目前仅支持身份证号段前3或后6位"
            style="display: flex; margin: 0 20px 0 0"
          >
          </el-form-item>
        </div>

        <div style="display: flex; margin: 0 0 15px 0">
          <el-form-item label="备注" style="display: flex; margin: 0 20px 0 0" prop="remark">
            <el-input
              type="textarea"
              :rows="2"
              style="width: 800px"
              placeholder="请输入内容"
              v-model="airportadd.remark"
            >
            </el-input>
          </el-form-item>
        </div>
        <div style="display: flex; margin: 0 0 15px 0">
          <el-form-item
          prop="cardId"
            label="适合会员卡号"
            style="display: flex; margin: 0 20px 0 0"
          >
            <el-input
              type="textarea"
              :rows="2"
              style="width: 800px"
              placeholder="请输入内容"
              v-model="airportadd.cardId"
            >
            </el-input>
          </el-form-item>
          <el-form-item
            label="为空则代表适用所有会员卡号，多个卡号用 | 隔开"
            style="display: flex; margin: 0 20px 0 0"
          >
          </el-form-item>
        </div>
        <!-- <div style="display: flex; margin: 0 0 15px 0">
          <el-form-item
          prop="allClasses"
            label="所有舱位"
            style="display: flex; margin: 0 20px 0 0"
          >
            <el-input
              type="textarea"
              :rows="2"
              style="width: 800px"
              placeholder="请输入内容"
              v-model="airportadd.allClasses"
            >
            </el-input>
          </el-form-item>
        </div>
        <div style="display: flex; margin: 0 0 15px 0">
          <el-form-item
          prop="suitableClass"
            label="适合舱位"
            style="display: flex; margin: 0 20px 0 0"
          >
            <el-input
              type="textarea"
              :rows="2"
              style="width: 800px"
              placeholder="请输入内容"
              v-model="airportadd.suitableClass"

            >
            </el-input>
          </el-form-item>
        </div>
        <div style="display: flex; margin: 0 0 15px 0">
          <el-form-item
          prop="applicableFlights"
            label="所有航班"
            style="display: flex; margin: 0 20px 0 0"
          >
            <el-input
              type="textarea"
              :rows="2"
              style="width: 800px"
              placeholder="请输入内容"
              v-model="airportadd.applicableFlights"
            >
            </el-input>
          </el-form-item>
        </div>
        <div style="display: flex; margin: 0 0 15px 0">
          <el-form-item
          prop="allFlights"
            label="适合航班"
            style="display: flex; margin: 0 20px 0 0"
          >
            <el-input
              type="textarea"
              :rows="2"
              style="width: 800px"
              placeholder="请输入内容"
              v-model="airportadd.allFlights"

            >
            </el-input>
          </el-form-item>
        </div> -->
        <div style="display: flex; margin: 0 0 15px 0">
          <el-form-item
          prop="regulation"
            label="退改签规定"
            style="display: flex; margin: 0 20px 0 0"
          >
            <el-input
              type="textarea"
              :rows="2"
              style="width: 800px"
              placeholder="请输入内容"
              v-model="airportadd.regulation"

            >
            </el-input>
          </el-form-item>
        </div>
        <div style="display: flex; margin: 0 0 15px 0">
          <div style="color: red">
            提示：出发地和到达地可多个，用英文输入法下的逗号隔开
          </div>
          <!-- <el-form-item
            label="提示：出发地和到达地可多个，用英文输入法下的逗号隔开"
            style="display: flex; margin: 0 20px 0 0"
          >
          </el-form-item> -->
        </div>
        <el-form-item style="display: flex; margin: 0 20px 0 45%">
          <el-button type="primary" @click="determineairPort('ruleForm')"
            >确 定</el-button
          >
           
          <el-button @click="dialogVisible = false">取 消</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
    <!-- 删除 -->
    <el-dialog
      title="确认删除"
      :close-on-click-modal="false"
      :visible.sync="delDialogVisible"
      width="30%"
      center
    >
      <span>确认删除此条直降产品政策吗</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="delDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="getdelRemoveflightRevisecabinprice()"
          >确 定</el-button
        >
      </span>
    </el-dialog>
    <!-- 分页 -->
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[10, 15, 20]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="pageTotal"
    >
    </el-pagination>
  </div>
</template>

<script>
export default {
  name: "discountProduct",
  data() {
    return {
      // 维护类型
      chooseType:"1",
      // 慧讯会员信息条件
      selectdata: {
        phone: "",
        customerId: "",
      },
      // 查询回来的数据
      custmerdata: [],
      // 删除弹窗
      delDialogVisible: false,
      // 查询会员弹窗
      selecrdisable: false,
      //分页
      pageSize: 10,
      currentPage: 1,
      pageTotal: 0,

      // 适合周期
      checked: true,
      // 航空公司
      airportLists: [],
      // 弹窗
      dialogVisible: false,
      // 时间格式
      format: "yyyy-MM-dd",
      // 表格
      ruleForm: {
        departure: "", //出发地
        destination: "", //到达地
        airline: "", //航空公司
        id:null,
        startTime: new Date(new Date() - (3600 * 1000 * 24 * 7 + 1000))
          .toLocaleDateString()
          .replace(/\//g, "-"), //   日期时间
        endTime: new Date(new Date().getTime() +86400000).toLocaleDateString().replace(/\//g, "-"),

        partner: "", //合作商
      },
      pricetypeList: [
        {
          label: "比例",
          value: "1",
        },
        {
          label: "金额",
          value: "2",
        },
      ],
      // 证件类型下拉
      idTypeList: [
        {
          label: "身份证",
          value: "1",
        },
        {
          label: "护照",
          value: "2",
        },
        {
          label: "其他",
          value: "3",
        },
      ],
      // 删除id
      delreviseid: "",
      // 报销凭证下拉
      credentialsList: [
        {
          label: "行程单",
          value: "行程单",
        },
        {
          label: "发票",
          value: "发票",
        },
        // {
        //   label: "行程单+差额发票",
        //   value: "3",
        // },
      ],
      // 列表
      auxiliary: [],
      // 航空公司
      imagestate: [],
      // 城市
      querySearch: [],
      // 新增数据
      airportadd: {
        id: "", //修改id
        airlinerId: "", //航司二字码
        cabin: "", //舱位
        policystarttime: "", //起飞开始时间
        policyendtime: "", //起飞结束时间
        citycode: null, //出票城市
        issuancestarttime: "", //预定开始时间
        issuanceendtime: "", //预定结束时间
        departureList: [], //出发城市三字码
        arrivalList: [], //到达城市三字码
        applicableFlights: "", //适用航班
        adjusttype: "", //调整类型 1 比例 2 金额
        adjustmoney: "", //调整金额数量
        returnType: "", //返现类型1比例，2金额
        returnMoney: "", //返现金额
        customerIdList: [], //会员id集合
        ismatchcabin: "", //是否匹配原舱退改签 0否 1是
        offLine: "", //0线上自动返现，1线下手工返现
        enabled: "", //是否激活0否1是
        cabinalias: "", //舱位标识
        salesexplain: "", //促销说明
        cabinTag: "", //舱位标签
        cabinGradeName: "", //舱位等级名称
        peopleMin: null, //人数限制 最小
        peopleMax: "", //人数限制 最大
        ageMin: "", //年龄限制 最小
        ageMax: "", //年龄限制 最大
        credentials: "", //报销凭证
        idType: "", //证件类型
        idBigint: "", //证件号码
        remark: "", //备注
        cardId: "", //会员卡号，多个用| 隔开
        allClasses:"",//所有舱位
        suitableClass:"",//适合舱位
        allFlights:"",//所有航班
        regulation:"",//退改签规定
        baggage:""
      },
        suitweekList: [], //适用周期
        accessTypeList: [], //适用显示区域（1:CRM，2:外网，3:App）


      // 校验
      rules: {
        airlinerId: [{ required: true, message: "请选择航空公司", trigger: "change" }],
        baggage: [{ required: true, message: "请输入行李额", trigger: "blur" }],
        cabin: [{ required: true, message: "请输入仓位", trigger: "blur" }],
        policystarttime: [{ required: true, message: "请选择起飞起止时间", trigger: "change" }],
        citycode: [{ required: true, message: "请选择出票城市", trigger: "change" }],
        issuancestarttime: [{ required: true, message: "请选择预定起止时间", trigger: "change" }],
        departureList: [{ required: true, message: "请选择出票城市", trigger: "change" }],
        arrivalList: [{ required: true, message: "请选择到达城市", trigger: "change" }],
        // suitweekList: [{ required: true, message: "请选择至少一个适合周期", trigger: "change" }],
        // accessTypeList: [{ required: true, message: "请选择至少一个适合显示区域", trigger: "change" }],
        adjusttype: [{ required: true, message: "请选择价格调整类型", trigger: "change" }],
        adjustmoney: [{ required: true, message: "请输入金额比例", trigger: "blur" }],
        returnType: [{ required: true, message: "请选择返现类型", trigger: "change" }],
        returnMoney: [{ required: true, message: "请输入返现金额", trigger: "blur" }],
        offLine: [{ required: true, message: "请选择返现类型", trigger: "change" }],
        ismatchcabin: [{ required: true, message: "请选择是否匹配原舱退改签", trigger: "change" }],
        enabled: [{ required: true, message: "请选择是否激活", trigger: "change" }],
        cabinalias: [{ required: true, message: "请输入舱位识别", trigger: "blur" }],
        salesexplain: [{ required: true, message: "请输入促销说明", trigger: "blur" }],
        cabinTag: [{ required: true, message: "请输入舱位标签", trigger: "blur" }],
        cabinGradeName: [{ required: true, message: "请输入舱位等级名称", trigger: "blur" }],
        peopleMin: [{ required: true, message: "请输入人数限制", trigger: "blur" }],
        ageMin: [{ required: true, message: "请输入年龄限制", trigger: "blur" }],
        credentials: [{ required: true, message: "请选择报销凭证", trigger: "change" }],
        idType: [{ required: true, message: "请选择证件类型", trigger: "change" }],
        idBigint: [{ required: true, message: "请输入证件号段", trigger: "blur" }],
        // remark: [{ required: true, message: "请输入备注", trigger: "blur" }],
        // cardId: [{ required: true, message: "请输入适合会员卡号", trigger: "blur" }],
        // allClasses: [{ required: true, message: "请输入所有舱位", trigger: "blur" }],
        // suitableClass: [{ required: true, message: "请输入适合舱位", trigger: "blur" }],
        // applicableFlights: [{ required: true, message: "请输入所有航班", trigger: "blur" }],
        // allFlights: [{ required: true, message: "请输入适合航班", trigger: "blur" }],
        // regulation: [{ required: true, message: "请输入退改签规定", trigger: "blur" }],
        
      },
      arrcustomername: [],
      // 中转赋值数据
      arrcustomernamevoluation: [],
      arrcustomeridvoluation: [],
    };
  },
  mounted() {},
  methods: {
    seachBtn(){
         localStorage.setItem("pageSize", 10);
        localStorage.setItem("pageNum", 1); 
      this.getselectFlightRevisecabinpriceList()
    },
    // 新增接口
    getaddflightRevisecabinprice() {
      if(this.airportadd.customerIdList ==""){
        this.airportadd.customerIdList =[]
      }   if(this.airportadd.arrivalList ==""){
        this.airportadd.arrivalList =[]
      }  
        if(this.airportadd.departureList ==""){
        this.airportadd.departureList =[]
      }  
      console.log(this.airportadd.customerIdList)
      localStorage.setItem("isToken", true);
      this.$axios
        .getaddflightRevisecabinprice({
          cabinTag:this.airportadd.cabinTag,
          baggage:this.airportadd.baggage,
          airlinerId: this.airportadd.airlinerId, //航司二字码
          cabin: this.airportadd.cabin, //舱位
          policystarttime: this.airportadd.policystarttime, //起飞开始时间
          policyendtime: this.airportadd.policyendtime, // //起飞结束时间
          citycode: this.airportadd.citycode, //出票城市
          issuancestarttime: this.airportadd.issuancestarttime, // //预定开始时间
          issuanceendtime: this.airportadd.issuanceendtime, //预定结束时间
          departureList: this.airportadd.departureList, //出发城市三字码
          arrivalList: this.airportadd.arrivalList, //到达城市三字码
          applicableFlights: this.airportadd.applicableFlights, //适用航班
          suitweekList: this.suitweekList, //适用周期

          accessTypeList: this.accessTypeList, //适用显示区域（1:CRM，2:外网，3:App）
          adjusttype: Number(this.airportadd.adjusttype), //调整类型 1 比例 2 金额
          adjustmoney: Number(this.airportadd.adjustmoney), //调整金额数量
          returnType: Number(this.airportadd.returnType), //返现类型1比例，2金额
          returnMoney: Number(this.airportadd.returnMoney), //返现金额
          customerIdList: this.airportadd.customerIdList, //会员id集合
          ismatchcabin: Number(this.airportadd.ismatchcabin), //是否匹配原舱退改签 0否 1是
          ismatchcabin: Number(this.airportadd.ismatchcabin), //是否匹配原舱退改签
          offLine: Number(this.airportadd.offLine), //0线上自动返现，1线下手工返现
          enabled: Number(this.airportadd.enabled), //是否激活0否1是
          cabinalias: this.airportadd.cabinalias, //舱位标识
          salesexplain: this.airportadd.salesexplain, //促销说明
          cabinGradeName: this.airportadd.cabinGradeName, //舱位等级名称
          peopleMin: Number(this.airportadd.peopleMin), //人数限制 最小
          peopleMax: Number(this.airportadd.peopleMax), //人数限制 最大
          ageMin: Number(this.airportadd.ageMin), //年龄限制 最小
          ageMax: Number(this.airportadd.ageMax), //年龄限制 最da
          credentials: this.airportadd.credentials, //报销凭证
          idType: this.airportadd.idType, //证件类型
          idBigint: this.airportadd.idBigint, //证件号码
          remark: this.airportadd.remark, //备注
          cardId: this.airportadd.cardId, //会员卡号，多个用| 隔开
          allClasses: this.airportadd.allClasses, //所有舱位
          suitableClass: this.airportadd.suitableClass, //适合舱位
          allFlights: this.airportadd.allFlights, //所有航班
          regulation: this.airportadd.regulation, //退改签规定
        })
        .then((res) => {
          console.log(res);
          if (res.code == "200") {
            
            this.dialogVisible= false
            this.getselectFlightRevisecabinpriceList()
            this.$message({
              message: '新增成功',
             type: 'success'
           });

          }
        });
    },
    // 修改接口
    geteditflightRevisecabinprice() {
      localStorage.setItem("isToken", true);
      this.$axios
        .geteditflightRevisecabinprice({
          cabinTag:this.airportadd.cabinTag,
          baggage:this.airportadd.baggage,
          reviseid:this.airportadd.id,//修改主键id
          airlinerId: this.airportadd.airlinerId, //航司二字码
          cabin: this.airportadd.cabin, //舱位
          policystarttime: this.airportadd.policystarttime, //起飞开始时间
          policyendtime: this.airportadd.policyendtime, // //起飞结束时间
          citycode: this.airportadd.citycode, //出票城市
          issuancestarttime: this.airportadd.issuancestarttime, // //预定开始时间
          issuanceendtime: this.airportadd.issuanceendtime, //预定结束时间
          departureList: this.airportadd.departureList, //出发城市三字码
          arrivalList: this.airportadd.arrivalList, //到达城市三字码
          applicableFlights: this.airportadd.applicableFlights, //适用航班
          suitweekList: this.suitweekList, //适用周期

          accessTypeList: this.accessTypeList, //适用显示区域（1:CRM，2:外网，3:App）
          adjusttype: Number(this.airportadd.adjusttype), //调整类型 1 比例 2 金额
          adjustmoney: Number(this.airportadd.adjustmoney), //调整金额数量
          returnType: Number(this.airportadd.returnType), //返现类型1比例，2金额
          returnMoney: Number(this.airportadd.returnMoney), //返现金额
          customerIdList: this.airportadd.customerIdList, //会员id集合
          ismatchcabin: Number(this.airportadd.ismatchcabin), //是否匹配原舱退改签 0否 1是
          ismatchcabin: Number(this.airportadd.ismatchcabin), //是否匹配原舱退改签
          offLine: Number(this.airportadd.offLine), //0线上自动返现，1线下手工返现
          enabled: Number(this.airportadd.enabled), //是否激活0否1是
          cabinalias: this.airportadd.cabinalias, //舱位标识
          salesexplain: this.airportadd.salesexplain, //促销说明
          cabinGradeName: this.airportadd.cabinGradeName, //舱位等级名称
          peopleMin: Number(this.airportadd.peopleMin), //人数限制 最小
          peopleMax: Number(this.airportadd.peopleMax), //人数限制 最大
          ageMin: Number(this.airportadd.ageMin), //年龄限制 最小
          ageMax: Number(this.airportadd.ageMax), //年龄限制 最da
          credentials: this.airportadd.credentials, //报销凭证
          idType: this.airportadd.idType, //证件类型
          idBigint: this.airportadd.idBigint, //证件号码
          remark: this.airportadd.remark, //备注
          cardId: this.airportadd.cardId, //会员卡号，多个用| 隔开
          allClasses: this.airportadd.allClasses, //所有舱位
          suitableClass: this.airportadd.suitableClass, //适合舱位
          allFlights: this.airportadd.allFlights, //所有航班
          regulation: this.airportadd.regulation, //退改签规定
        })
        .then((res) => {
          console.log(res);
          if (res.code == "200") {
            
      this.dialogVisible= false
      this.getselectFlightRevisecabinpriceList()
this.$message({
          message: '修改成功',
          type: 'success'
        });
          }
        });
    },

    // tabel点击事件
    handleSelectionChange(val) {
      this.arrcustomernamevoluation.push(val[0].customerName);
      this.arrcustomeridvoluation.push(val[0].customerId);
      console.log(this.arrcustomername);
      console.log(this.airportadd.customerIdList);
    },
    // 确定按钮赋值
    voluationdata() {
      (this.custmerdata = []), (this.selectdata = {});
      (this.arrcustomername = this.arrcustomernamevoluation),
        (this.airportadd.customerIdList = this.arrcustomeridvoluation);
      this.selecrdisable = false;
    },
    // 查询会员
    getqueryCRMCustomerData() {
      if (this.selectdata.customerId != "" || this.selectdata.phone != "") {
        this.$axios
          .getqueryCRMCustomerData({
            customerId: this.selectdata.customerId,
            phone: this.selectdata.phone,
          })
          .then((res) => {
            this.custmerdata = [];

            console.log(res);
            if (res.code == "200") {
              this.custmerdata.push(res.data);
            }
          });
      } else {
        this.$message({
          message: "查询会员id与手机号任选其一",
          type: "warning",
        });
      }
    },
    // 城市
    getselectCityList() {
      this.$axios.getselectCityList({}).then((res) => {
        console.log(res);
        if (res.code == "200") {
          let list = JSON.parse(JSON.stringify(res.data));
          this.querySearch = list.map((item) => {
            return { label: item.cityName, value: item.cityCode };
          });
          // console.log(this.querySearch);
        }
      });
    },
    // 航司列表接口
    getairportList() {
      localStorage.removeItem("pageNum");
      localStorage.removeItem("pageSize");
      this.$axios.getairportList({}).then((res) => {
        console.log(res);
          localStorage.setItem("pageSize", 10);
          localStorage.setItem("pageNum", 1);
        if (res.code == "200") {
          this.airportLists = res.data;
      
        }
      });
    },
    //分页
    handleSizeChange(value) {
      console.log("1", value);
      localStorage.setItem("pageSize", value);
      localStorage.setItem("pageNum", 1);
      this.getselectFlightRevisecabinpriceList();
      this.pageSize = value;
    },
    handleCurrentChange(value) {
      console.log("2", value);

      localStorage.setItem("pageNum", value);
      localStorage.setItem("pageSize", this.pageSize);
      this.currentPage = value
      this.getselectFlightRevisecabinpriceList();
      // orders = res.data;
    },

    search() {
      localStorage.setItem("pageNum", this.currentPage);
      localStorage.setItem("pageSize", 10);
      this.getselectFlightRevisecabinpriceList();
    },
    // 查询列表
    getselectFlightRevisecabinpriceList() {
       localStorage.setItem("pageSize", this.pageSize);
          localStorage.setItem("pageNum", this.currentPage);
      this.$axios
        .getselectFlightRevisecabinpriceList({
          departure: this.ruleForm.departure,
          destination: this.ruleForm.destination,
          airline: this.ruleForm.airline,
          startTime: this.ruleForm.startTime,
          endTime: this.ruleForm.endTime,
          partner: this.ruleForm.partner,
          id:this.ruleForm.id
        })
        .then((res) => {
          console.log(res);
          // debugger
          if (res.code == "200") {
            this.auxiliary = res.data;
            this.pageTotal = res.total;
          }
        });
    },

    // 新增按钮
    newairPort() {
      
      let form= this.airportadd
Object.keys(form).forEach(key => (form[key] = ''));
this.getselectFlightRevisecabinpriceList()
      this.dialogVisible = true;
    },
    // 新增保存按钮
    determineairPort(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          // alert("11111111111111111");
          if(this.airportadd.id==''){
               this.getaddflightRevisecabinprice();
          }else{
  
              this.geteditflightRevisecabinprice()
               
            
          }
        
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    // 删除点击事件
    delairPort(row) {
      console.log(row);
      this.delreviseid = row.reviseid;
      this.delDialogVisible = true;
    },
    // 删除接口
    getdelRemoveflightRevisecabinprice() {
      this.$axios
        .getdelRemoveflightRevisecabinprice({
          id: this.delreviseid,
        })
        .then((res) => {
          console.log(res);
          // debugger
          if (res.code == "200") {
            this.getselectFlightRevisecabinpriceList();
            this.delDialogVisible = false;
            this.$message({
              message: "删除成功",
              type: "success",
            });
          }
        });
    },
    //修改点击事件
    editdatamethod(row) {
      console.log(row);
      this.airportadd = row
      if(row.suitweek){this.suitweekList = row.suitweek.split(",")}
      if(row.accessType){this.accessTypeList = row.accessType.split(",")}
      this.airportadd.id = row.reviseid
      this.airportadd.returnType = String(row.returnType)
      this.airportadd.ismatchcabin = String(row.ismatchcabin)
      this.airportadd.enabled = String(row.enabled)
      this.airportadd.offLine = String(row.offLine)
      this.airportadd.adjusttype = String(row.adjusttype)
      console.log(this.airportadd.id);
      this.dialogVisible = true;
      if(row.arrival!=""){
        let arrivalList =row.arrival.split("]")[0].split("[")[1].split(",")
        let aList=[]
        for (let i = 0; i < arrivalList.length; i++) {
            aList[i] = arrivalList[i].replace(/^\s*/g, '')
        }
        this.airportadd.arrivalList=aList
      }
      if(row.departureList!=""){
        this.airportadd.departureList = row.departure.split(",")
      }
    },
  },
  mounted() {
    // 列表
    this.getselectFlightRevisecabinpriceList();
    // 城市
    this.getselectCityList();
    this.getairportList();
  },
};
</script>

<style  scoped>
.discountProduct {
  margin: 20px;
}
</style>